package com.kiln.juxingqs.adapter

import android.content.Context
import android.content.Intent
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import client.global.commlib.base.BaseLoadmoreAdapter
import client.global.commlib.base.BindingViewHoder
import com.kiln.juxingqs.R
import com.kiln.juxingqs.api.bean.GetDddBatchRet
import com.kiln.juxingqs.databinding.LayoutLotskjyItemBinding
import com.kiln.juxingqs.ui.ApplyDeliveryActivity

class ZrLotsKjyAdapter : BaseLoadmoreAdapter<GetDddBatchRet.Batch> {


    constructor(context: Context) : super(context) { }

    override fun createVh(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return BindingViewHoder(
            DataBindingUtil.inflate(
                layoutInflater,
                R.layout.layout_lotskjy_item,
                parent,
                false
            )
        )
    }

    override fun bindVh(holder: RecyclerView.ViewHolder, position: Int) {
        val bindingViewHolder = holder as BindingViewHoder<ViewDataBinding>
        val binding = bindingViewHolder.binding as LayoutLotskjyItemBinding

        val bean = getItem(position)
        binding.bean = bean
        binding.event = this
        val time = bean.create_time.substring(
            5,
            bean.create_time.length - 3

        )
        binding.time = time
        binding.tvOperation.isVisible = false //隐藏操作

        /*when(bean.r_state){
            1->{
                binding.num="+${bean.num}"
            }
            2->{
                binding.num="-${bean.num}"
            }
        }
        binding.bean=bean*/
    }

    fun goTIhuo(bean: GetDddBatchRet.Batch) {
        context.startActivity(Intent(context, ApplyDeliveryActivity::class.java).apply {
            putExtra("goods_id", bean.goods_id.toString())
            putExtra("goods_name", bean.name)
            putExtra("deal_num", bean.deal_num.toString())
        })
    }

}
